package cn.ac.siom.query.dao.impl;

import cn.ac.siom.query.dao.WordCountDao;
import cn.ac.siom.query.vo.WordCount;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class WordCountDaoImpl extends SqlSessionDaoSupport implements WordCountDao {

    @Autowired
    public WordCountDaoImpl(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    @Override
    public Integer insert(WordCount wordCount) {
        return super.getSqlSession().insert("WordCount.insert", wordCount);
    }

    @Override
    public List<WordCount> queryAll() {
        Map map = new HashMap<>();
        return super.getSqlSession().selectList("WordCount.selectAll", map);
    }


    @Override
    public Integer deleteAll() {
        Map map = new HashMap<>();
        return super.getSqlSession().delete("WordCount.delete", map);
    }
}
